<style scoped>
    .corporate-factory-page{}

</style>
<template> 
    <div class="corporate-factory-page">
        <el-form :inline="true" :model="formInline" class="demo-form-inline" style="border-bottom:1px solid #ccc;">

            <!--法人名称-->
            <el-form-item :label="nowLangue.legalName" class="selectMB10 label-w1" >
                <el-select size="mini" clearable v-model="formInline.legalPersonName"  @change="selectLegalPersonCode" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(legalPerson,index) in legalPersonLists" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.legalPersonName">
                    </el-option>
                </el-select>
            </el-form-item>
            <!--备件集合-->
            <el-form-item :label="nowLangue.factory" class="purchase_label selectMB10 label-w1" >
                <el-select size="mini" clearable v-model="formInline.plantCode"  :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(spart,index) in spartList" :key="index" :label="spart.legalPlantCode" :value="spart.legalPlantDec">
                    </el-option>
                </el-select>
            </el-form-item>
            <!--备件编码-->
            <el-form-item :label="nowLangue.beijianName" class="selectMB10">
                <el-input size="mini" v-model="formInline.spartName" :placeholder="nowLangue.pleaseImport+nowLangue.beijianName"></el-input>
            </el-form-item>
            <!--备件小类下拉框-->
            <el-form-item :label="nowLangue.beijianXiaoLei" class="selectMB10">
                <el-select size="mini" clearable  v-model="formInline.subclassCode" :placeholder="nowLangue.beijianXiaoLei">
                    <el-option v-for="(subClass,index) in subClassList" :key="index" :label="subClass.name" :value="subClass.code">
                    </el-option>
                </el-select>
            </el-form-item>

            <!--阈值-->
            <el-form-item :label="nowLangue.beijianshuliangfazhikaishi" class="selectMB10">
                <el-input size="mini" v-model="formInline.fazhiStart" :placeholder="nowLangue.pleaseImport+nowLangue.beijianshuliangfazhikaishi"></el-input>
            </el-form-item>
            <!--阈值-->
            <el-form-item :label="nowLangue.beijianshuliangfazhijieshu" class="selectMB10">
                <el-input size="mini" v-model="formInline.fazhiEnd" :placeholder="nowLangue.pleaseImport+nowLangue.beijianshuliangfazhijieshu"></el-input>
            </el-form-item>

            <!--修改日期开始-->
            <el-form-item :label="nowLangue.xiugaikaishishijian" class="selectMB10">
                <el-date-picker type="date" size="mini" :editable="false" v-model="formInline.startTime" :placeholder="nowLangue.pleaseSelect" class="selectMB10" prop="startTime" @change="selectedStartTime"></el-date-picker>
            </el-form-item>
            <!--修改日期结束-->
            <el-form-item :label="nowLangue.xiugaijieshuriqi" class="selectMB10">
                <el-date-picker type="date" size="mini" :editable="false" v-model="formInline.endTime" :placeholder="nowLangue.pleaseSelect" class="selectMB10" prop="endTime"  @change="selectedEndTime"></el-date-picker>
            </el-form-item>

            <!--修改人员-->
            <el-form-item :label="nowLangue.xiugairenyuan" class="selectMB10">
                <el-input size="mini" v-model="formInline.updateName" :placeholder="nowLangue.pleaseImport+nowLangue.xiugairenyuan"></el-input>
            </el-form-item>

            <el-form-item class="selectMB10">
                <!--查询-->
                <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" @click="queryCorFactSheet()" v-text="nowLangue.query"></el-button>
            </el-form-item>
        </el-form>
        <!--表格-->
        <!--法人所属工厂明细列表：-->
        <label class="default-label" v-text="nowLangue.legalFactoryList"></label>
        <!--新增按钮-->
        <!--新增-->
        <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="createNew()" v-text="nowLangue.create"></el-button>
        <el-table :data="corFactoryData" border style="width: 100%;" v-loading.body="loading" element-loading-text="拼命加载中">
            <!--序-->
            <el-table-column type="index" header-align="center" align="center" :label="nowLangue.sequence"  width="40"></el-table-column>
            <!--操作-->
            <el-table-column :label="nowLangue.operate" header-align="center" align="center" width="80">
                <template scope="scope">
                    <!--修改-->
                    <button class="operationItem bolder"  @click="updateCorFact(scope.$index,scope.row)" v-text="nowLangue.update"></button>
                </template>
            </el-table-column>
            <!--备件编码-->
            <el-table-column prop="bjCode" :label="nowLangue.beijianbianma" header-align="center" width="100"  show-overflow-tooltip></el-table-column>
            <!--备件名称-->
            <el-table-column prop="bjName" :label="nowLangue.beijianmingcheng" header-align="center" show-overflow-tooltip></el-table-column>
            <!--计量单位-->
            <el-table-column prop="fazhi" :label="nowLangue.jiliangdanwei" header-align="center" align="center"  width="80" show-overflow-tooltip></el-table-column>
            <!--备件小类-->
            <el-table-column prop="name" :label="nowLangue.beijianlei" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <!--数量阈值-->
            <el-table-column prop="fazhi" :label="nowLangue.fazhi" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="shistatus" :label="nowLangue.shistatus" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="jieyong" :label="nowLangue.jieyong" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="xiaoshou" :label="nowLangue.xiaoshou" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="beizhu" :label="nowLangue.beizhu" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="legalPersonName" :label="nowLangue.legalName" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="createName" :label="nowLangue.createName" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="createTime" :label="nowLangue.createTime" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="updateName" :label="nowLangue.updateName" header-align="center"  width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="updateTime" :label="nowLangue.updateTime" header-align="center"  width="100" show-overflow-tooltip></el-table-column>

        </el-table>
        <!--分页-->
        <el-pagination v-if="isPaging" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageIndex"  :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :page-count="totalPage" :total="totalNumber"></el-pagination>
        <!--新建弹窗-->
        <!--新增工厂信息-->
        <el-dialog :title="nowLangue.create+nowLangue.factoryMes" :visible.sync="dialogForm1Visible" size="tiny" :lock-scroll="false">
            <el-form :inline="true" :model="addCorFactData" class="demo-form-inline label-minW80" style="border-bottom:1px solid #ccc;" ref="addCorFactData">
                <!--法人名称-->
                <el-form-item :label="nowLangue.legalName" class="selectMB10 label-w1" >
                    <el-select size="mini" clearable v-model="addCorFactData.legalPersonCode"   @change="selectSpareCode" :placeholder="nowLangue.pleaseSelect">
                        <el-option v-for="(legalPerson,index) in legalPersonLists" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.legalPersonCode">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--备件编码-->
                <el-form-item :label="nowLangue.bjName" class="purchase_label selectMB10 label-w1" >
                    <el-select size="mini" clearable v-model="addCorFactData.bjCode"  @change="selectSpareCode" :placeholder="nowLangue.pleaseSelect">
                        <el-option v-for="(spart,index) in spartList" :key="index" :label="spart.bjName" :value="spart.bjCode">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--备件名称-->
                <el-form-item :label="nowLangue.beijianName" class="selectMB10"  >
                    <el-input  v-model="addCorFactData.spareName" disabled></el-input>
                </el-form-item>
                <!--备件小类-->
                <el-form-item :label="nowLangue.beijianlei" class="selectMB10"  >
                    <el-input  v-model="addCorFactData.subClassName" disabled></el-input>
                </el-form-item>
                <!--阈值数量-->
                <el-form-item :label="nowLangue.shuliangfazhi" prop="fazhi"  :rules="[{ required: true, message: nowLangue.required}]" >
                    <el-input  v-model.trim="addCorFactData.fazhi" :placeholder="nowLangue.pleaseImport+nowLangue.factoryCode"></el-input>
                </el-form-item>
                <!--备注-->
                <el-form-item :label="nowLangue.beizhu" prop="remark"  >
                    <el-input  v-model.trim="addCorFactData.remark" :placeholder="nowLangue.pleaseImport+nowLangue.factoryCode"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <!--保存-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="saveCorFact" v-text="nowLangue.save" :disabled="saveCFDisabled"></el-button>
                <!--取消-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="cancleCorFact" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
        <!--修改弹窗-->
        <!--修改工厂信息-->
        <el-dialog :title="nowLangue.update+nowLangue.factoryMes" :visible.sync="dialogForm2Visible" size="tiny" :lock-scroll="false">
            <el-form :inline="true" :model="updateCorFactData" class="demo-form-inline label-minW80" style="border-bottom:1px solid #ccc;" ref="updateCorFactData">
                <!--法人名称-->
                <el-form-item :label="nowLangue.legalName" class="selectMB10">
                    <el-input  v-model="updateCorFactData.legalPersonName" disabled></el-input>
                </el-form-item>
                <!--法人编码-->
                <el-form-item :label="nowLangue.bjName" class="selectMB10">
                    <el-input  v-model="updateCorFactData.bjName" disabled></el-input>
                </el-form-item>
                <!--工厂编码-->
                <el-form-item :label="nowLangue.factoryCode" class="selectMB10">
                    <el-input  v-model.trim="updateCorFactData.bjCode" disabled></el-input>
                </el-form-item>

                <!--备件小类名称-->
                <el-form-item :label="nowLangue.beijianlei" class="purchase_label selectMB10 label-w1" >
                    <el-select size="mini" clearable v-model="updateCorFactData.name"  @change="selectSpareCode" :placeholder="nowLangue.pleaseSelect">
                        <el-option v-for="(spart,index) in spartList" :key="index" :label="spart.name" :value="spart.Code">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--工厂描述-->
                <el-form-item :label="nowLangue.fazhi" prop="fazhi"  :rules="[{ required: true, message: nowLangue.required}]" >
                    <el-input  v-model.trim="updateCorFactData.fazhi" :placeholder="nowLangue.pleaseImport+nowLangue.fazhi"></el-input>
                </el-form-item>



                <!--状态-->
                <el-form-item :label="nowLangue.status" class="selectMB10" >
                    <el-radio-group v-model="updateCorFactData.status">
                        <!-- 启用 -->
                        <el-radio :label="true" v-cloak>{{nowLangue.status}}</el-radio>
                        <!-- 禁用 -->
                        <el-radio :label="false" v-cloak>{{nowLangue.forbidden}}</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <!--保存-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="saveUpdateCorFact" v-text="nowLangue.save" :disabled="saveUCFDisabled"></el-button>
                <!--取消-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="cancleUpdateCorFact" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                nowLangue:{},
                // 查询表单
                formInline:{
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                     spareCode:"",
                     bjCode:"",
                    plantCode:"",
                    spareName:"",
                    bjName:"",
                    name:"",
                    dname:"",
                     subClassName:"",
                    subclassCode:"",
                    fazhiStart:"",
                    fazhiEnd:"",
                    updateName:"",
                    updateTimeStart:"",
                    updateTimeEnd:"",
                    fazhi:"",
                },
                labelWidth:"80px",
                addCorFactData:{
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                    // legalPersonId:"",//法人ID
                     fazhi:"",//法人ID
                     name:"",//法人ID
                    bjCode:"",
                    bjName:"",//备件编码
                     remark:"",//法人ID
                     spareCode:"",//法人ID
                    legalPlantCode:"",
                    legalPlantDec:"",
                    status:true
                },
                updateCorFactData:{
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                    // legalPersonId:"",//法人ID
                    legalPlantCode:"",
                    legalPlantDec:"",
                    bjCode:"",
                    fazhi:"",
                    name:"",
                    code:"",
                    status:"",
                    version:""
                },
                legalPersonLists:[], //法人下拉框
                spartList:[],//备件列表
                loading:false,
                disabled:false,
                // radio:1,//默认启用


                //弹窗
                dialogForm1Visible:false,
                dialogForm2Visible:false,
                // 分页
                isPaging:false,
                pageIndex:1,    //当前页（必传）
                pageSize :10,   //每页多少条
                totalNumber: 20,
                totalPage:2,
                //查询禁用
                selectDisabled:false,
                saveCFDisabled:false,      //新建弹窗中保存操作按钮禁用
                saveUCFDisabled:false      //修改弹窗中保存操作按钮禁用
            };
        },
        created:function(){
            var _this=this;
            _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
        },
        computed:{
            // powerData(){
            //     return this.$store.state.powerData;
            // },
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                var _this=this;
                _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
            }
        },
        //进入页面立即运行此方法
        mounted: function () {
            var _this = this;
            _this.$store.commit('currentActive', 'CorporateFactory');
        //    //ajax前后查询按钮禁用
        //    $(".selectAll").ajaxStart(function(){
        //        _this.selectDisabled=true;
        //    });
        //    $(".selectAll").ajaxStop(function(){
        //        _this.selectDisabled=false;
        //    });
            _this.legalPersonDropDownValue();//获取法人列表下拉框值
            _this.beijianDropDownValue();//获取备件编码下拉框值
            _this.queryCorFactSheet();    //表单查询
            _this.factoryDropDownValue();    //表单查询
       },
        methods:{
            // 查询条件 法人名称 下拉列表的值
            legalPersonDropDownValue(){  //法人名称下拉列表值
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.procurement_service+"legalPerson/ofCurrentUser",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.legalPersonLists = data.data;
                            //
                            _this.factoryDropDownValue(_this.formInline.legalPersonCode);
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //备件编码下拉框
            beijianDropDownValue(){  //法人名称下拉列表值
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.procurement_service+"beiJian/query",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.spartList = data.data;
                            //
                            _this.factoryDropDownValue(_this.formInline.bjCode);
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 下拉列表选择法人名称
            selectLegalPersonCode(){
                var _this=this;
//                _this.formInline.legalPlantCode = "";
                _this.formInline.legalPersonCode = "";
                //遍历全部法人信息
                for(var i=0;i<_this.legalPersonLists.length;i++){
                    //如果当前的法人名称等于遍历出来的法人名称
                    if(_this.formInline.legalPersonName==_this.legalPersonLists[i].legalPersonName){
                        //给表单中的id和code赋值
//                        _this.formInline.legalPersonId=_this.legalPersonLists[i].id;
                        _this.formInline.legalPersonCode=_this.legalPersonLists[i].legalPersonCode;
                    }
                }
                _this.factoryDropDownValue(_this.formInline.legalPersonCode);
            },
            selectSpareCode(){
                var _this=this;
                _this.addCorFactData.spareName = "";
                _this.addCorFactData.subClassName = "";
                _this.addCorFactData.bjName = "";
                for(var i=0;i<_this.spartList.length;i++){
                    //如果当前的法人名称等于遍历出来的法人名称
                    if(_this.addCorFactData.spareCode==_this.spartList[i].spareCode){
                        _this.addCorFactData.spareName=_this.spartList[i].spareName;
                        _this.addCorFactData.subClassName=_this.spartList[i].subClassName;
                        _this.addCorFactData.bjName=_this.spartList[i].bjName;
                        _this.addCorFactData.bjCode=_this.spartList[i].bjCode;
                    }
                }
                _this.spareDropDownValue(_this.addCorFactData.legalPersonCode);
            },
           /* selectSpareCode2(){
                var _this=this;
                _this.formInline.spareName = "";
                _this.formInline.subClassName = "";
                for(var i=0;i<_this.spartList.length;i++){
                    //如果当前的法人名称等于遍历出来的法人名称
                    if(_this.formInline.spareCode==_this.spartList[i].spareCode){
                        _this.formInline.spareName=_this.spartList[i].spareName;
                        _this.formInline.subClassName=_this.spartList[i].subClassName;
                    }
                }
                _this.spareDropDownValue(_this.formInline.legalPersonCode);
            },*/
            // 查询条件 工厂下拉列表 根据法人code查
            factoryDropDownValue(legalPersonCode){
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"legalPerson/queryCode",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.spartList = data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 查询条件
            spareDropDownValue(legalPersonCode){
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"spare/querySpareDropDownValue?legalPersonCode="+legalPersonCode,
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.spartList = data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //法人名称下拉列表值
            /*legalPersonDropDownValue(){
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.procurement_service+"legalPerson/ofCurrentUser",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.legalPersonDropDown = data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },*/
            //查询法人所属工厂明细列表
            queryCorFactSheet(){
                var _this=this;
                _this.loading=true;
                var tmp={
                    legalPersonCode:_this.formInline.legalPersonCode,
                    bjName:_this.formInline.bjName,
//                    bjCode:_this.formInline.bjCode,
//                    subclassCode:_this.formInline.subclassCode,
                    fazhi:_this.formInline.fazhi,
                    fazhiStart:_this.formInline.fazhiStart,
                    fazhiEnd:_this.formInline.fazhiEnd,
                    updateName:_this.formInline.updateName,
                    updateTimeStart:_this.formInline.updateTimeStart,
                    updateTimeEnd:_this.formInline.updateTimeEnd,
                    pageIndex:_this.pageIndex,
                    pageSize:_this.pageSize
                };
                _this.selectDisabled=true;
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"part/queryFa",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            _this.loading=false;
                            _this.isPaging=true;
                            _this.totalPage=data.data.totalPage;
                            _this.totalNumber=data.data.totalNumber;
                            _this.corFactoryData=data.data.dataList;
                            // 当前状态的显示
                            for(var i=0;i<_this.corFactoryData.length;i++){
                                if(_this.corFactoryData[i].enabled){
                                    _this.corFactoryData[i].enabled='启用';
                                }else{
                                    _this.corFactoryData[i].enabled='禁用';
                                }
                            }
                        }else{
                            _this.common.errorTip(data.errorMessage)
                        }
                        _this.selectDisabled=false;
                    }
                });
            },
            //新增法人所属工厂信息
            createNew(){
                var _this=this;
                _this.dialogForm1Visible=true;
                if(this.$refs['addCorFactData']) {
                    this.$refs['addCorFactData'].resetFields();
                }
                _this.addCorFactData.legalPersonName = '';
                _this.addCorFactData.legalPersonCode = '';
                _this.addCorFactData.legalPlantCode='';
                _this.addCorFactData.legalPlantDec="";
                _this.addCorFactData.bjCode="";
                _this.addCorFactData.status = false;
            },
            //新建保存
            saveCorFact(){
                var _this=this;
                _this.$refs["addCorFactData"].validate((valid) => {
                    if (valid) {
                        var tmp={
                            legalPersonCode:_this.addCorFactData.legalPersonCode,
                            bjCode:_this.addCorFactData.bjCode,
                            fazhi:_this.addCorFactData.fazhi,
                            remark:_this.addCorFactData.remark,
                        };
                        _this.saveCFDisabled=true;
                        $.ajax({
                            type: 'POST',
                            url: _this.metadata_service+"fazhi/add11",
                            cache: false,
                            data:JSON.stringify(tmp),
                            dataType:'JSON',
                            contentType: "application/json;charset=utf-8",
                            success: function (data) {
                                if (data.success) {
                                    var success=_this.languageType=="zh"?'保存成功':'Save Success';
                                    _this.common.successTip(success);
                                    _this.dialogForm1Visible=false;
                                    _this.queryCorFactSheet();
                                }else{
                                    _this.common.errorTip(data.errorMessage);
                                }
                                _this.saveCFDisabled=false;
                            }
                        });
                    } else {
                        var err=_this.common.formErrorInfo();
                        _this.common.errorTip(err);
                        return false;
                    }
                });
            },
            //新建取消
            cancleCorFact(){
                var _this=this;
                _this.dialogForm1Visible=false;
                if(this.$refs['addCorFactData']) {
                    this.$refs['addCorFactData'].resetFields();
                }
                _this.addCorFactData.legalPersonName="";
                _this.addCorFactData.legalPersonCode = '';
                _this.addCorFactData.legalPlantCode="";
                _this.addCorFactData.legalPlantDec="";
                _this.addCorFactData.status=false;
            },
            // 操作启用禁用
            handleStatus(index, row){
                var _this=this;
                if(row.status == '启用'){
                    row.status = false;
                }else{
                    row.status = true;
                }
                var tmp={id: row.id,
                legalPlantCode:row.legalPlantCode,
                legalPersonCode:row.legalPersonCode,
                    status: row.status}; // legalPlantDec:row.legalPlantDec, 描述不传
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"legalPlant/updatestatus",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            // 当前状态的显示
                            if(row.status){
                                row.status = "启用";
                                var success=_this.languageType=="zh"?'启用成功':'Enable success';
                                _this.common.successTip(success);
                            }else{
                                row.status = "禁用";
                                var success=_this.languageType=="zh"?'禁用成功':'Disable success';
                                _this.common.successTip(success);
                            }
                        }else
                            _this.common.errorTip(data.errorMessage);
                    }
                });
            },
            //点击修改
            updateCorFact(index,row){
                var _this=this;
                _this.dialogForm2Visible=true;
                if(this.$refs['updateCorFactData']) {
                    this.$refs['updateCorFactData'].resetFields();
                 }
                 _this.updateCorFactData.bjCode = row.bjCode;
                 _this.updateCorFactData.legalPersonCode = row.legalPersonCode;
                 _this.updateCorFactData.bjName = row.bjName;
                 _this.updateCorFactData.legalPersonName = row.legalPersonName;
                 _this.updateCorFactData.legalPlantDec = row.legalPlantDec;
                 _this.updateCorFactData.code = row.code;
                 _this.updateCorFactData.name = row.name;
                 _this.updateCorFactData.number = row.fazhi;
                 _this.updateCorFactData.status = row.status;
//                 _this.updateCorFactData.version = row.version;

                if(_this.updateCorFactData.status=='禁用'){
                    _this.updateCorFactData.status=false;
                }else if(_this.updateCorFactData.status=='启用'){
                    _this.updateCorFactData.status=true;
                }
            },
            //修改保存
            saveUpdateCorFact(){
                var _this=this;
                _this.$refs["updateCorFactData"].validate((valid) => {
                    if (valid) {
                        var tmp={
                        legalPlantCode:_this.updateCorFactData.legalPlantCode,
                        legalPersonCode:_this.updateCorFactData.legalPersonCode,
                        code:_this.updateCorFactData.code,
                        name:_this.updateCorFactData.name,
                        legalPersonName:_this.updateCorFactData.legalPersonName,
                        legalPlantDec:_this.updateCorFactData.legalPlantDec,
                            status: _this.updateCorFactData.status,
                            fazhi: _this.updateCorFactData.fazhi,
                            bjCode: _this.updateCorFactData.bjCode,
                        version: _this.updateCorFactData.version};
                        _this.saveUCFDisabled=true;
                        $.ajax({
                            type: 'POST',
                            url: _this.metadata_service+"fazhi/update",
                            cache: false,
                            data:JSON.stringify(tmp),
                            dataType:'JSON',
                            contentType: "application/json;charset=utf-8",
                            success: function (data) {
                                if (data.success) {
                                    var success=_this.languageType=="zh"?'修改成功！':'Modify successfully';
                                    _this.common.successTip(success);
                                    _this.dialogForm2Visible=false;
                                    _this.queryCorFactSheet();
                                }else{
                                    _this.common.errorTip(data.errorMessage);
                                }
                                _this.saveUCFDisabled=false;    
                            }
                        });
                    } else {
                        var err=_this.common.formErrorInfo();
                        _this.common.errorTip(err);
                        return false;
                    }
                });

            },
            //修改取消
            cancleUpdateCorFact(){
                var _this=this;
                _this.dialogForm2Visible=false;
            },
            //   分页
            handleSizeChange(val) {
                // console.log(`每页 ${val} 条`);
                var _this=this;
                _this.pageSize=val;
                _this.queryCorFactSheet();

            },
            //点击页码分页查询点击事件
            handleCurrentChange(val) {
                // console.log(`当前页: ${val}`);
                var _this=this;
                _this.pageIndex=val;
                _this.queryCorFactSheet();
            }
        }
    }
</script>



